package com.spic.business.staff.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.spic.common.log.annotation.Log;
import com.spic.common.log.enums.BusinessType;
import com.spic.business.staff.domain.StaffBasicData;
import com.spic.business.staff.service.IStaffBasicDataService;
import com.spic.common.core.web.controller.BaseController;
import com.spic.common.core.web.domain.AjaxResult;
import com.spic.common.core.web.page.TableDataInfo;

/**
 * 人员基本资料Controller
 *
 * @author ruoyi
 * @date 2023-03-23
 */
@RestController
@RequestMapping("/staff_basic_data")
public class StaffBasicDataController extends BaseController
{
    @Autowired
    private IStaffBasicDataService staffBasicDataService;

    /**
     * 查询人员基本资料列表
     */
    @GetMapping("/list")
    public TableDataInfo list(StaffBasicData staffBasicData)
    {
        startPage();
        List<StaffBasicData> list = staffBasicDataService.selectStaffBasicDataList(staffBasicData);
        return getDataTable(list);
    }

//    /**
//     * 导出人员基本资料列表
//     */
//    @Log(title = "人员基本资料", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, StaffBasicData staffBasicData)
//    {
//        List<StaffBasicData> list = staffBasicDataService.selectStaffBasicDataList(staffBasicData);
//        ExcelUtil<StaffBasicData> util = new ExcelUtil<StaffBasicData>(StaffBasicData.class);
//        util.exportExcel(response, list, "人员基本资料数据");
//    }

    /**
     * 获取人员基本资料详细信息
     */
    @PostMapping("/getInfo")
    public AjaxResult getInfo(@RequestBody StaffBasicData staffBasicData)
    {
        return AjaxResult.success(staffBasicDataService.selectStaffBasicDataByUserName(staffBasicData));
    }

    /**
     * 新增人员基本资料
     */
    @Log(title = "人员基本资料", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StaffBasicData staffBasicData)
    {
        return toAjax(staffBasicDataService.insertStaffBasicData(staffBasicData));
    }

    /**
     * 修改人员基本资料
     */
    @Log(title = "人员基本资料", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StaffBasicData staffBasicData)
    {
        return toAjax(staffBasicDataService.updateStaffBasicData(staffBasicData));
    }

    /**
     * 删除人员基本资料
     */
    @Log(title = "人员基本资料", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(staffBasicDataService.deleteStaffBasicDataByIds(ids));
    }

    /**
     * 获取证书资料
     */
    @GetMapping(value = "/certificate/{identityCard}")
    public AjaxResult getCertificatesList(@PathVariable("identityCard") String identityCard)
    {
        return AjaxResult.success(staffBasicDataService.getCertificatesList(identityCard));
    }

    /**
     * 查询违章记录
     */
    @GetMapping(value = "/getViolationList/{username}")
    public AjaxResult getViolationList(@PathVariable("username") String username)
    {
        return AjaxResult.success(staffBasicDataService.getViolationList(username));
    }

    /**
     * 查询培训信息
     */
    @GetMapping(value = "/train/{personnelCode}")
    public AjaxResult getTrainInfo(@PathVariable("personnelCode") String personnelCode)
    {
        return AjaxResult.success(staffBasicDataService.getTrainInfo(personnelCode));
    }
}
